package tawai;

import javax.microedition.lcdui.game.Sprite;

/**
 * Class models tank shell explosion
 *
 * @author Alex
 */
public class Explosion implements IterativelyActive, Drawable {

    /**
     * Explosion sprite
     */
    private Sprite sprite;

    /**
     * Constructor<br>
     * Initializes sprite
     * 
     * @param initSprite Explosion sprite
     */
    public Explosion (Sprite initSprite) {

        sprite = initSprite;
        sprite.setFrame(3);
    }

    /**
     * Explosion should draw full sprite's cycle and disappear
     *
     * @see IterativelyActive
     */
    public void performIterativeAction() {
       
        sprite.nextFrame();
        if (sprite.getFrame() == 3) { // If cycle is done, remove itself from scene
            TawaiMIDlet.getMain().removeSceneObject(this);
        }
    }

    /**
     * @see Drawable
     */
    public Sprite getSprite() {

        return sprite;
    }

}
